﻿using Little.Soldier.SWIFT;
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;

namespace Little.Soldier
{
    internal sealed class ISwiftBlock5 : ExpandableObjectConverter
    {
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
          if (destinationType == typeof (InstanceDescriptor))
            return true;
          else
            return base.CanConvertTo(context, destinationType);
        }

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType != typeof (InstanceDescriptor) || value.GetType().FullName != "LittleSoldier.SwiftBlock5")
            return base.ConvertTo(context, culture, value, destinationType);
            else
            return (object) new InstanceDescriptor((MemberInfo) typeof (SwiftBlock5).GetConstructor(Type.EmptyTypes), (ICollection) null, false);
        }
    }
}
